package com.example.design.patterns.冰河.创建型模式.单例;

/**
 * 代码一：懒汉模式，线程不安全
 */
public class SingletonExample1 {
    private static SingletonExample1 instance = null;

    ;

    private SingletonExample1() {
    }

    private static SingletonExample1 getInstance() {
        // 多个线程同时调用，可能会创建多个对象
        if (instance == null) {
            instance = new SingletonExample1();
        }
        return instance;
    }
}
